// DocumentStatisticalAnalysisWebPage.cpp: implementation of the CDocumentStatisticalAnalysisWebPage class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AUSlotsTester.h"
#include "DocumentStatisticalAnalysisWebPage.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDocumentStatisticalAnalysisWebPage::CDocumentStatisticalAnalysisWebPage( const CAUSlotsTesterDoc* pDoc ) :
	CDocumentWebPage( pDoc )
{
}

CDocumentStatisticalAnalysisWebPage::~CDocumentStatisticalAnalysisWebPage()
{
}

void CDocumentStatisticalAnalysisWebPage::GenerateBodyContent()
{
	BeginTable( haCenter );

		BeginRow();

			BeginColumn();

			EndColumn();

			BeginColumn( 50 );

			EndColumn();

			BeginColumn( haCenter );

				BeginBold();
				
					InsertContent( _T( "Expected" ) );

				EndBold();

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn();
		
				BeginBold();

				InsertContent( _T( "vs." ) );

				EndBold();

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn( haCenter );

				BeginBold();

					InsertContent( _T( "Observed" ) );

				EndBold();

			EndColumn();

			BeginColumn( 50 );

			EndColumn();

			BeginColumn();

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn( 3, 9 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "True Standard Deviation*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( _T( "N/A*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetTrueStandardDeviation(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn( haRight );

				InsertContent( _T( "N/A*" ) );

			EndColumn();
		
		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "Approximate Standard Deviation*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetExpectedStandardDeviation(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetStandardDeviation(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn( haRight );

				InsertContent( GetResults().GetStandardDeviation() - GetResults().GetExpectedStandardDeviation(), 5 );

			EndColumn();
		
		EndRow();

		BeginRow();

			BeginColumn( 3, 9 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "True Variance*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( _T( "N/A*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetTrueVariance(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn( haRight );

				InsertContent( _T( "N/A*" ) );

			EndColumn();
		
		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "Approximate Variance*" ) );

			EndColumn();

			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetExpectedVariance(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();
			
			BeginColumn();

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetVariance(), 5 );

			EndColumn();

			BeginColumn();

			EndColumn();
			
			BeginColumn( haRight );

				InsertContent( GetResults().GetVariance() - GetResults().GetExpectedVariance(), 5 );

			EndColumn();
		
		EndRow();

		BeginRow();

			BeginColumn( 3, 9 );

			EndColumn();
		
		EndRow();

		BeginRow();

			BeginColumn( 800, false, -1, false, haDefault, vaDefault, 9, crWhite );

				InsertContent( _T("*The expected true standard deviation is extremely difficult to calculate due to the recursion caused by free game features.  However it is very easy to calculate the observed true standard deviation since we only have to use the observed spins as input.  The approximate standard deviation is determined by averaging the payout from free game features and using the average as input, to overcome the recursion issue.  Of course this has a tendency to understate the true standard deviation since a lot of the game's volatility is caused by the free game features.  The approximate standard deviation is only an estimate of the true standard deviation and the expected value is given on the submission sheet for the game.  This all applies to the variance as well since it is based on the standard deviation.") );

			EndColumn();

		EndRow();

	EndTable();

	InsertContent( _T( "&nbsp;" ) );

	BeginTable( haCenter );
	
		BeginRow();

			BeginColumn( haCenter, 3 );

				BeginBold();

					InsertContent( _T( "Additional Observed Variables" ) );

				EndBold();

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn( 3, 3 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "Sampling Distribution" ) );

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetSamplingDistribution(), 5 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "Standard Normal Cumulative Distribution" ) );

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetStandardNormalCumulativeDistribution(), 5 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "Z of Costly" ) );

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetZOfCostly(), 5 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn();

				InsertContent( _T( "P of Costly" ) );

			EndColumn();

			BeginColumn( 10 );

			EndColumn();

			BeginColumn( haRight );

				InsertContent( GetResults().GetPOfCostly(), 5 );

			EndColumn();

		EndRow();

		BeginRow();

			BeginColumn( 3, 3 );

			EndColumn();

		EndRow();

	EndTable();
}

LPCTSTR CDocumentStatisticalAnalysisWebPage::GetSubTitle() const
{
	return _T( "Statistical Analysis" );
}
